package com.morizhang.merchanmanager.api.bean;

import com.morizhang.merchanmanager.api.monitor.IMonitor;
import com.morizhang.merchanmanager.api.monitor.MonitorAnnotation;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class MonitorHolder {
    private static Map<String, Scheduler> MonitorList = new HashMap<>();

    public static void registerNewMonitor(String monitorName, Scheduler scheduler) {
        MonitorList.put(monitorName, scheduler);
    }

    public static void startMonitor(String monitorName) throws SchedulerException {
        MonitorList.get(monitorName).start();
    }

    public static void stopMonitor(String monitorName) throws SchedulerException {
        MonitorList.get(monitorName).shutdown();
    }
}
